package superminer.xinfang.com.ipreport.network;

import android.util.Log;

import superminer.xinfang.com.ipreport.util.MyGson;
import superminer.xinfang.com.ipreport.util.netty.NettyClient;

import java.util.HashMap;
import java.util.Map;

/**
 * tcp 的网络请求
 * Created by Administrator on 2018/3/22.
 */

public class TcpNetHelper {
    public static final int Login =30;//登录
    public static final int ReLogin = 31;//登录返回
    public static final int ChangeIPs = 32;//修改IP
    public static final int ReChangeIP= 33;//修改返回
    public static final int IpReport = 3;//矿机发送IP信息

    public static final int SENDSUCC = -4;//发送成功
    public static final int UNLOGIN = -3;//未登录



    /**
     * 登录
     * @param UserName
     * @param Password
     */
    public static void login(String UserName, String Password) {

        Map<String, String> map = new HashMap<>();
        map.put("UserName", UserName);
        map.put("Password", Password);
        String json = MyGson.getInstance().toJson(map);
        NettyClient.getInstance().sendMessage(Login,json, 0);
    }

    /**
     * 修改ip
     * @param MinerIP 以前ip
     * @param ChangeIP 修改后的Ip
     */
    public static void changeIP(String MinerIP, String ChangeIP) {

        Map<String, String> map = new HashMap<>();
        map.put("MinerIP", MinerIP);
        map.put("ChangeIP", ChangeIP);
        String json = MyGson.getInstance().toJson(map);
        NettyClient.getInstance().sendMessage(ChangeIPs,json, 0);
    }




}
